<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="../vue.js" charset="utf-8"></script>
      </head>
      <body>
        <div id="demo">
            num: {{num}}<br/>
            string: {{string}}<br/>
            arr: {{arr}}<br/>
            obj: {{obj}}<br/>
        </div>
      </body>
      <script type="text/javascript">
            var data= {a:{}},val ;
            Object.defineProperty(data.a,"b",{
                set:function(newValue){
                    val = newValue ;
                    console.log("你要赋值给我,我的新值是:",newValue)
                    },
                get:function(){
                    console.log("你取我的值")
                    return val //注意这里，我硬编码返回2
                }
            });

            var vm = new Vue({
            el:"#demo",
            data:{
                num:1,
                string:'afsd',
                arr : [[]],
                obj: {}
            },
            watch: {
                $data: {
                    handler(value) {
                        console.log('asdfasdf');
                    },
                    deep: true,
                }
            },
            created () {
                this.$watch(function(){
                    console.log('updated',this.arr.length);
                })
            }
        });
      </script>
</html>